www.gusucode.com > VC++.Net 编写COM组件实例+调用测试-源码程序 > VC++.Net 编写COM组件实例+调用测试-源码程序/code/COMTest/COMTest.cpp
//Download by http://www.NewXing.com /*// COMTest.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" int _tmain(int argc, _TCHAR* argv[]) { return 0; } */ #include "stdafx.h" #include <iostream> #include "atlbase.h" #import "..\MyServer\_MyServer.tlb" no_namespace using namespace std; struct OleCom { OleCom() { CoInitialize(NULL);} ~OleCom() { CoUninitialize(); } }olecom; int _tmain(int argc, _TCHAR* argv[]) { CComPtr<IUnknown> spUnknown; spUnknown.CoCreateInstance(__uuidof(CObject1)); CComPtr<IObject1> pI; spUnknown.QueryInterface(&pI); short res = 0; pI->get_GetANum(&res); cout << res << endl; return 0; }